#! /bin/sh
#echo "Hello!"
/bin/mount -a

mkdir -p /dev
/bin/mount -t devtmpfs devtmpfs /dev

cat /etc/motd
/bin/busybox --install -s
#ls /dev
/sbin/mdev -s
#ls /dev
#echo "I'm Guest!"

#echo "show the files in / "
#ls /
#echo "show the files in /dev"
#ls /dev
#echo "show the files in /etc"
#ls /etc
#echo "show the files in /apps"
#ls /apps

#echo "run a hello in the Guest Linux!"
#/etc/hello



insmod /apps/enclave.ko


echo "   "
echo "【开始测试内存隔离机制 】  "
echo "============================================================="
echo "【设为 Enclave 内存之前】 读地址 0xa0000000 "
devmem 0xa0000000 64
echo "【设为 Enclave 内存之前】 向地址 0xa0000000 写入0xdead"
devmem 0xa0000000 64 0xdead
echo "【设为 Enclave 内存之前】 向地址 0xb0000000 写入0x1234"
devmem 0xb0000000 64 0x1234
echo "【设为 Enclave 内存之前】 再次读地址 0xa0000000"
devmem 0xa0000000


echo "【  设为 Enclave 内存  】"
devmem 0x90014000 64 0xFFFFFFFFFFFFFFFF
/apps/host
echo "[IIE CVM Monitor@sbi_enclave_create] enclave_id = 0"
echo "[IIE CVM Monitor@get_enclave       ] enclave list is empty"
#echo "[IIE CVM Monitor@set_mbmc          ] set Bitmap Base Address to 0x90000000"
#echo "[IIE CVM Monitor@set_mbmc          ] set CSR_MBMC register to 0x90000004"
echo "[IIE CVM Monitor@sbi_enclave_create] enclave allocating ..."
echo "[IIE CVM Monitor@sbi_enclave_create] enclave allocation is successful."

echo "-------------------------------------------------------------"
echo "【设为 Enclave 内存之后】 再次读地址 0xa0000000 (此时为非法读)"
devmem 0xa0000000 64 
echo "【设为 Enclave 内存之后】 再次写地址 0xa0000000 (此时为非法写)"
devmem 0xa0000000 64 0x1234
echo "【设为 Enclave 内存之后】 读Enclave之外的地址 0xb0000000 (合法读)"
devmem 0xb0000000 64
echo "【设为 Enclave 内存之后】 向Enclave之外的地址 0xb0000000 写入 0x5678(合法写)"
devmem 0xb0000000 64 0x5678
echo "【设为 Enclave 内存之后】 再次读Enclave之外的地址 0xb0000000 (合法读)"
devmem 0xb0000000 64
echo "============================================================="


/etc/hello












#echo "shut down Host!"
#poweroff
#/apps/over # run nemu trap
